#include<bits/stdc++.h>
using namespace std;
const int mod = 998244353;
long long qmi(long long a,int b)
{
	long long res = 1;
	while(b)
	{
		if(b & 1) (res *= a) %= mod;
		(a *= a) %= mod;
		b >>= 1;
	}
	return res;
}
long long fac[10000011],exfac[10000011],mi[10000011];
int n,k;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	freopen("length.in","r",stdin);
	freopen("length.out","w",stdout);
	cin >> n >> k;
	k %= mod - 1;
	mi[0] = 1;
	for(int i = 1;i <= n;i++) mi[i] = mi[i - 1] * n % mod;
	fac[0] = 1;
	for(int i = 1;i <= n;i++) fac[i] = fac[i - 1] * i % mod;
	exfac[n] = qmi(fac[n],mod - 2);
	for(int i = n;i;i--) exfac[i - 1] = exfac[i] * i % mod;
	long long ans = 0;
	for(int i = 1;i <= n;i++)
		ans += fac[n] * exfac[n - i] % mod * mi[n - i] % mod * qmi(i,k - 1) % mod;
	cout << ans % mod << "\n";
	return 0;
}